package com.ls.task.bean;

import java.util.Calendar;
import java.util.Date;

public class ComparableDate implements Comparable<Date>{
	private Date date;
	
	public ComparableDate(Date date) {
		super();
		this.date = date;
	}

	@Override
	public int compareTo(Date newDate) {
		 Calendar oldCal = Calendar.getInstance();
	     Calendar newCal = Calendar.getInstance();
	     oldCal.setTime(date);
	     newCal.setTime(newDate);
	     if (oldCal.before(newCal)) {
	    	 return -1;
	     }
	     if (oldCal.equals(newCal)) {
	    	 return 0;
	     }
	     if (oldCal.after(newCal)) {
	    	 return 1;
	     }
		 return 0;
	}
}